import axios from 'axios'
import store from "@/store"
const request = axios.create({
    // 接口的基准路径
    baseURL: 'http://ttapi.research.itcast.cn/',
  
  })
 export default request



 request.interceptors.request.use(function (config) {
  // Do something before request is sent
  const {user}=store.state
  if(user&&user.token){config.header}
  return  config.headers.Authorization = `Bearer ${user.token}`
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});